import type { TableColumn } from '@/framework/components/core/super-table';
import dayjs from 'dayjs';
import { i18n } from '@/locales';

export type TableListItem = {
  id: number | string;
  shareState: 1 | 2;
  keyword?: string;
  serial: string;
  originalSerial: string;
  name: string;
  sampleAddress: string;
  createTime: string;
  lastInPerson: string;
};
export type TableColumnItem = TableColumn<TableListItem>;

// @ts-ignore
export const baseColumns: TableColumnItem[] = [
  {
    title: '关键字',
    field: 'keyword',
    hideInTable: true,
  },
  {
    title: '状态',
    field: 'shareState',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: [
          { label: '共享', value: 1 },
          { label: '已入库未共享', value: 2 },
        ],
        allowClear: false,
      },
      defaultValue: 1,
    },
    hideInTable: true,
  },
  {
    type: 'checkbox',
    title: '',
    width: 60,
  },
  {
    type: 'seq',
    title: '序号',
    width: 60,
  },
  {
    title: '序列号',
    field: 'serial',
    hideInSearch: true,
  },
  {
    // @ts-ignore
    title: i18n.global.t('specimen.original_serial'),
    field: 'originalSerial',
    hideInSearch: true,
  },
  {
    // @ts-ignore
    title: i18n.global.t('specimen.name'),
    field: 'name',
    hideInSearch: true,
  },
  {
    title: '来源',
    field: 'sampleAddress',
    hideInSearch: true,
  },
  {
    title: '创建时间',
    field: 'createTime',
    hideInSearch: true,
    formatter: ({ cellValue }) => {
      return cellValue ? dayjs(cellValue).format('YYYY-MM-DD') : '-';
    },
  },
  {
    title: '创建者',
    field: 'lastInPerson',
    hideInSearch: true,
  },
];
